<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/pages/mastertemplate/MasterPage.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui" xmlns:syn="http://www.syniverse.com">
	<ui:define name="content">
		<p:panel header="#{msg.nhanvien_title}">
			<h:form>
				<p:fileUpload widgetVar="fileuplaod_wgt"
					fileUploadListener="#{NhanVienBean.handleFileUpload}"
					mode="advanced" dragDropSupport="false" update=":nhanVienForm"
					sizeLimit="100000" fileLimit="1"
					allowTypes="/(\.|\/)(#{DataConfigBean.fileExtensionPattern})$/" />
			</h:form>
			<h:form>
				<p:commandButton style="width:150px;float: left;margin-top:10px;"
					value="#{msg.Button_export}"
					actionListener="#{NhanVienBean.downloadFileCSV}" ajax="false">
					<p:fileDownload value="#{NhanVienBean.file}" />
				</p:commandButton>
			</h:form>

			<h:form id="nhanVienForm">
				<p:growl id="growforFile" autoupdate="true"
					life="#{DataConfigBean.growlShow}" />
				<p:dataTable id="dataTable" var="nhanvien"
					value="#{NhanVienBean.nhanVienModel}" lazy="true" paginator="true"
					rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="10,20,50,100"
					style="width: 100%; margin: 45px auto;">

					<f:facet name="header">
						<h:outputText value="#{msg.danhsachNhanVien}"
							styleClass="tableHeader" />
						<div style="margin: -4px -11px 5px; float: right;">
							<p:commandButton style="height: 25px"
								update=":addNhanVienForm:display" value="+ thêm mới"
								rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
								actionListener="#{NhanVienBean.notifyAdd}"
								onclick="PF('NhanVienDialog').show();">
							</p:commandButton>
						</div>

					</f:facet>

					<p:column headerText="#{msg.maNhanVien}">#{nhanvien.maNhanVien}  </p:column>

					<p:column headerText="#{msg.tenNhanVien}">  #{nhanvien.hoTen}   </p:column>

					<p:column headerText="#{msg.chucVu}">  #{nhanvien.chucVu}   </p:column>

					<p:column headerText="#{msg.phongBan}">  #{nhanvien.phongBan}   </p:column>

					<p:column style="width:60px;text-align: center;"
						headerText="#{msg.table_actions}">
						<p:commandButton styleClass="smallButton"
							icon="ui-icon ui-icon-pencil" update=":addNhanVienForm:display"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							action="#{NhanVienBean.notifyEdit(nhanvien)}"
							oncomplete="PF('NhanVienDialog').show();">

						</p:commandButton>
						<p:commandButton style="margin-left: 5px" styleClass="smallButton"
							icon="ui-icon ui-icon-trash"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							oncomplete="PF('confirmRemove').show();">
							<f:setPropertyActionListener value="#{nhanvien}"
								target="#{NhanVienBean.selectedNhanVien}" />
						</p:commandButton>
					</p:column>

				</p:dataTable>

				<p:dialog id="confirmRemove" header="#{msg.confirm}"
					widgetVar="confirmRemove" resizable="false">
					<table>
						<tr>
							<td><h:outputText value="#{msg.confirm_text}:" /></td>
							<td align="right"><p:commandButton value="#{msg.okButton}"
									actionListener="#{NhanVienBean.removeNhanVien}"
									update=":nhanVienForm" oncomplete="PF('confirmRemove').hide();" /></td>
						</tr>

					</table>
				</p:dialog>
			</h:form>
			<h:form id="addNhanVienForm">
				<p:dialog id="dialog" header="Thêm mới/ Sửa" modal="true"
					widgetVar="NhanVienDialog" resizable="false">

					<p:panel id="display">
						<table>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										for="maNhanVien" value="#{msg.maNhanVien}" /></td>
								<td><p:inputText styleClass="inputText" required="true"
										requiredMessage="#{msg.maNhanVien}: #{msg.valuerequired}"
										id="maNhanVien" value="#{NhanVienBean.nhanvien.maNhanVien}">

									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										for="tenNhanVien" value="#{msg.tenNhanVien}" /></td>
								<td><p:inputText styleClass="inputText" required="true"
										requiredMessage="#{msg.maNhanVien}: #{msg.valuerequired}"
										id="tenNhanVien" value="#{NhanVienBean.nhanvien.hoTen}">

									</p:inputText></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.gioiTinh}" /></td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{NhanVienBean.nhanvien.gioiTinh}">
										<f:selectItems value="#{NhanVienBean.listGioiTinh}"
											var="selectItem" itemLabel="#{selectItem}"
											itemValue="#{selectItem}" />
									</p:selectOneMenu></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.ngaysinh}" /></td>
								<td><p:calendar style="min-width:140px"
										value="#{NhanVienBean.nhanvien.ngaySinh}"
										pattern="#{DataConfigBean.datepattern}" showButtonPanel="true">
										<syn:convertTimestamp pattern="#{DataConfigBean.datepattern}" />
									</p:calendar></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.maSoThue}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.maSoThue}">
									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.phongBan}" /></td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{NhanVienBean.nhanvien.phongBan}"
										filter="true" filterMatchMode="contains">
										<f:selectItems value="#{PhongBanBean.listphongban}"
											var="selectItem" itemLabel="#{selectItem.tenPhongBan}"
											itemValue="#{selectItem.maPhongBan}" />
									</p:selectOneMenu></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.chucVu}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.chucVu}">

									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.soCMND}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.soCMND}">
									</p:inputText></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.noiCapCMND}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.noiCapCMND}">

									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.ngayCapCMND}" /></td>
								<td><p:calendar style="min-width:140px"
										value="#{NhanVienBean.nhanvien.ngayCapCMND}"
										pattern="#{DataConfigBean.datepattern}" showButtonPanel="true">
										<syn:convertTimestamp pattern="#{DataConfigBean.datepattern}" />
									</p:calendar></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.heSoLuong}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.heSoLuong}">
									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.giamTruGiaCanh}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.giamTruGiaCanh}">
									</p:inputText></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.diaChi}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.diaChi}">
									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.dTCoQuan}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.dTCoQuan}">
									</p:inputText></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.dTNhaRieng}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.dTNhaRieng}">

									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.dtDiDong}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.dTDiDong}">
									</p:inputText></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.email}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.email}">

									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.trangthai}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{NhanVienBean.nhanvien.trangthai}">

									</p:inputText></td>
							</tr>
							<tr>
								<td></td>
								<td></td>

								<td></td>
								<td align="right"><p:commandButton value="Lưu"
										actionListener="#{NhanVienBean.save}"
										update=":nhanVienForm :addNhanVienForm:display"
										oncomplete="if(args.opSuccess) PF('NhanVienDialog').hide()"></p:commandButton></td>
							</tr>
						</table>
					</p:panel>
				</p:dialog>
			</h:form>
			<p:panel header="Tìm chứng từ">
				<h:form>
					<table>
						<tr>
							<td><p:outputLabel style="margin-left: 20px" value="Từ ngày" /></td>
							<td><p:calendar style="min-width:140px"
									value="#{NhanVienBean.nhanvien.ngayCapCMND}"
									pattern="#{DataConfigBean.datepattern}" showButtonPanel="true">
									<syn:convertTimestamp pattern="#{DataConfigBean.datepattern}" />
								</p:calendar></td>
							<td><p:outputLabel style="margin-left: 20px"
									value="Đến ngày" /></td>
							<td><p:calendar style="min-width:140px"
									value="#{NhanVienBean.nhanvien.ngayCapCMND}"
									pattern="#{DataConfigBean.datepattern}" showButtonPanel="true">
									<syn:convertTimestamp pattern="#{DataConfigBean.datepattern}" />
								</p:calendar></td>
						</tr>
					</table>
				</h:form>

				<p:dataTable id="dataTable" lazy="true" paginator="true" rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="10,20,50,100"
					style="width: 100%; margin: 45px auto;">

					<f:facet name="header">
						<h:outputText value="Danh sách chứng từ" styleClass="tableHeader" />

					</f:facet>

					<p:column headerText="Loại chứng từ">
					</p:column>

					<p:column headerText="Ngày chứng từ">
					</p:column>

					<p:column headerText="Số chứng từ ">
					</p:column>

					<p:column headerText="Diễn giải">
					</p:column>



				</p:dataTable>
			</p:panel>
		</p:panel>
	</ui:define>
</ui:composition>
